# coding=utf-8
"""
    @project: qabot
    
    @file： team_serializers.py
    @date：2023/9/5 16:32
    @desc:
"""

from django.db.models import QuerySet
from rest_framework import serializers

from common.mixins.api_mixin import ApiMixin
from django.utils.translation import gettext_lazy as _
from common.util.field_message import ErrMessage
from xpack.models import application

class ApplicationSettingSerializer(ApiMixin, serializers.Serializer):
    class Meta:
        model = application.get_model_dict('application_setting')
        fields = ["platform", "id", "config", "app_id", "create_time", "update_time","is_valid","is_active"]
    application_id = serializers.UUIDField(required=True, error_messages=ErrMessage.uuid(_("Application ID")))
    def get_setting(self):
        title = _("Pro/Modify Application Settings")
        self.is_valid(raise_exception=True)
        application_id = self.data.get('application_id')
        try:
            application = QuerySet(Application).get(id=application_id)
            return application
        except Application.DoesNotExist:
            return None
    def set_setting(self, data):
        title = _("Pro/Modify Application Settings")
    
   
